Telegram Group & Telegram Channel
SOLID Principles
(part 3)
ثالث مبدأ(LSP) Liskov Substitution Principle

ليسكوف هو اسم العالمة اللي اقترحت هذا المبدأ وهو مبدأ الاستبدال والتعويض اللي يعرفك متى تعمل وراثة من كلاس ثاني ومتى لا وهذا المبدأ يُعتبر تكملة للمبدأ OCP.

‘‘If you have class B inherits from class A then class A should be replaceable by class B without any changes’’

بمعنى اذا كان B يورث من A فإن سلوك الـ client لن يتغير ويظل يعمل بكفاءة اذا استخدمنا B بدلاً من A.

لنفترض لدينا كلاس للطيور وفيها دالتين eat , fly ويوجد كلاسين اخرين(البطريق، النورس) يرثوا من الطيور.

من الطبيعي ان كُل كلاس اصبح يمتلك fly,eat .

لو انشئنا كائن من كلاس الطيور واستخدمنا الدالتين
Bird a = new Bird()
a.fly()
a.eat()

ومن ثَم غيرنا نوع الكائن لكلاس النورس.
Bird a = new Seagull()

فهل سلوك الـ client لن يتغير ويظل يعمل بكفاءة 🤔!

نعم ،لأنه النورس بُكل بساطه يطير ويأكل، إذاً هُنا طبقنا مبدأ ليسكوف.

طيب لو نغير نوع الكائن لكلاس البطريق !
Bird a = new Penguin()

هنا من الطبيعي جداً أن سلوك الـ clint يتغير ولن يعمل بكفاءة لأن البطريق يأكل ولاكن لا يطير ، إذاً هُنا تفشل عملية الوراثة .

طيب ايش الحل🤔؟

موضح في الصورة (2) 🙏.

وأخيراً متى يُستخدم هذا المبدأ ؟!

حينما نجد بأن الكلاسات الفرعية لا تتصرف بنفس الكيفية التي تتصرف بها الكلاسات الرئيسية .

لذلك نحتاج إلى تطبيق هذا المبدأ من أجل أن نضمن أن الكلاسات المُشتقة تستطيع أن تتصرف وكأنها كلاس رئيسي دون أن يؤثر على سلوك الـ client.

يتبع..



tg-me.com/beginprogrammer/635
Create:
Last Update:

SOLID Principles
(part 3)
ثالث مبدأ(LSP) Liskov Substitution Principle

ليسكوف هو اسم العالمة اللي اقترحت هذا المبدأ وهو مبدأ الاستبدال والتعويض اللي يعرفك متى تعمل وراثة من كلاس ثاني ومتى لا وهذا المبدأ يُعتبر تكملة للمبدأ OCP.

‘‘If you have class B inherits from class A then class A should be replaceable by class B without any changes’’

بمعنى اذا كان B يورث من A فإن سلوك الـ client لن يتغير ويظل يعمل بكفاءة اذا استخدمنا B بدلاً من A.

لنفترض لدينا كلاس للطيور وفيها دالتين eat , fly ويوجد كلاسين اخرين(البطريق، النورس) يرثوا من الطيور.

من الطبيعي ان كُل كلاس اصبح يمتلك fly,eat .

لو انشئنا كائن من كلاس الطيور واستخدمنا الدالتين
Bird a = new Bird()
a.fly()
a.eat()

ومن ثَم غيرنا نوع الكائن لكلاس النورس.
Bird a = new Seagull()

فهل سلوك الـ client لن يتغير ويظل يعمل بكفاءة 🤔!

نعم ،لأنه النورس بُكل بساطه يطير ويأكل، إذاً هُنا طبقنا مبدأ ليسكوف.

طيب لو نغير نوع الكائن لكلاس البطريق !
Bird a = new Penguin()

هنا من الطبيعي جداً أن سلوك الـ clint يتغير ولن يعمل بكفاءة لأن البطريق يأكل ولاكن لا يطير ، إذاً هُنا تفشل عملية الوراثة .

طيب ايش الحل🤔؟

موضح في الصورة (2) 🙏.

وأخيراً متى يُستخدم هذا المبدأ ؟!

حينما نجد بأن الكلاسات الفرعية لا تتصرف بنفس الكيفية التي تتصرف بها الكلاسات الرئيسية .

لذلك نحتاج إلى تطبيق هذا المبدأ من أجل أن نضمن أن الكلاسات المُشتقة تستطيع أن تتصرف وكأنها كلاس رئيسي دون أن يؤثر على سلوك الـ client.

يتبع..

BY بدايه مبرمج


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/beginprogrammer/635

View MORE
Open in Telegram


بدايه مبرمج Telegram | DID YOU KNOW?

Date: |

Export WhatsApp stickers to Telegram on iPhone

You can’t. What you can do, though, is use WhatsApp’s and Telegram’s web platforms to transfer stickers. It’s easy, but might take a while.Open WhatsApp in your browser, find a sticker you like in a chat, and right-click on it to save it as an image. The file won’t be a picture, though—it’s a webpage and will have a .webp extension. Don’t be scared, this is the way. Repeat this step to save as many stickers as you want.Then, open Telegram in your browser and go into your Saved messages chat. Just as you’d share a file with a friend, click the Share file button on the bottom left of the chat window (it looks like a dog-eared paper), and select the .webp files you downloaded. Click Open and you’ll see your stickers in your Saved messages chat. This is now your sticker depository. To use them, forward them as you would a message from one chat to the other: by clicking or long-pressing on the sticker, and then choosing Forward.

Look for Channels Online

You guessed it – the internet is your friend. A good place to start looking for Telegram channels is Reddit. This is one of the biggest sites on the internet, with millions of communities, including those from Telegram.Then, you can search one of the many dedicated websites for Telegram channel searching. One of them is telegram-group.com. This website has many categories and a really simple user interface. Another great site is telegram channels.me. It has even more channels than the previous one, and an even better user experience.These are just some of the many available websites. You can look them up online if you’re not satisfied with these two. All of these sites list only public channels. If you want to join a private channel, you’ll have to ask one of its members to invite you.

بدايه مبرمج from ar


Telegram بدايه مبرمج
FROM USA